<style scoped>
  .weui-form-preview {
    background-color: #fff;
    margin: 5px;
    border-radius: 5px;
  }

  .weui-form-preview__hd label, .weui-form-preview__hd em {
    font-size: .9em !important;
  }

  .rj-cell {
    display: inline-block;
    font-size: 0;
    padding: 5px 15px;
  }

  .rj-cell.max span {
    font-size: 16px;
    padding-right: 20px;
  }

  .rj-cell label {
    color: #333;
    font-size: 14px;
  }

  .rj-cell span {
    padding-left: 5px;
    font-size: 14px;
    color: #333;
  }

  .rj-cell.note {
    width: 100%;
  }

  .rj-cell.note label {
    float: left;
  }

  .rj-cell.note span {
    width: 80%;
    display: inline-block;
  }

  .weui-panel {
    background: #eee;
  }

  .rj-cont-tit {
    margin: 0;
    border-radius: 0;
  }

  .weui-panel {
    margin-top: 0;
    text-align: left;
  }

  .attachimg {
    /*width: 100%;*/
  }

  .tit label, .tit span {
    font-size: 16px;
  }

  .tit label {
    padding-right: 20px;
  }

  .weui-panel.weui-panel_access {
    padding-bottom: 10px;
  }

  .weui-panel__bd:not(.base) {
    width: auto;
    padding: 0 1% 2px 1%;
  }

  .rj-cont-tit:not(.base) {
    border-radius: 5px;
  }

  .weui-cell {
    background: #fff;
  }

  .weui-cells__title {
    text-align: left;
    background: #eee;
  }

  .oitem {
    padding: 3px;
  }

  #acts span {
    font-size: 14px;
  }

  .weui-label {
    text-align: left;
  }

  .weui-media-box {
    text-align: left;
  }

  .weui-panel {
    background: #eee;
  }

  .rj-cont-tit {
    margin: 0;
    border-radius: 0;
  }

  .weui-panel {
    margin-top: 0;
    text-align: left;
  }

  .rj-cell {
    font-size: 0.9em;
    display: inline-block;
    margin-right: 15px;
  }
  .section {
    margin: 5px;
    border-radius: 5px;
    text-align: left;
  }

  .hd .weui-grid.js_grid {
    font-weight: 600;
  }

  .weui-grid.js_grid {
    width: 25%;
    padding: 10px 1px;
  }
  .weui-grid__label {
    text-overflow: initial;
    min-height: 22px;
  }
  /*.weui-grids {*/
  /*  max-height: 80px;*/
  /*}*/
  .morebtn {
    text-align: center;
    font-size: 12px;
    padding: 3px 0;
    color: #04BE02;
    cursor: pointer;
  }
</style>
<template>
  <div class="comon" style="background: #eee;">
    <div
      style="height: 50px; line-height: 50px; background: #fff; text-align: center; font-size: 16px; border-bottom: 1px solid #bdbbbc; position: relative">
      运费支付详情
      <a href="javascript:;" @click="$router.back(-1)" style="position: absolute; left: 10px; top: 8px">
        <img src="@/assets/back.png" style="width: 20px"/>
      </a>
    </div>
    <!--    主表信息-->
    <div class="weui-form-preview" style="background: #fff;">
      <div class="weui-form-preview__hd">
        <label class="weui-form-preview__label">编号</label>
        <em class="weui-form-preview__value">{{baseInfo.code}}</em>
      </div>
      <div class="weui-form-preview__bd">
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">主体</label>
          <span class="weui-form-preview__value">{{baseInfo.orgname}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">部门</label>
          <span class="weui-form-preview__value">{{baseInfo.departname}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">物流公司</label>
          <span class="weui-form-preview__value">{{baseInfo.supplierName}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">物流单费用</label>
          <span class="weui-form-preview__value">{{attachUnit(baseInfo.applyAmount, ' 元')}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">其他费用</label>
          <span class="weui-form-preview__value">{{attachUnit(baseInfo.otheramount, ' 元')}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">费用总额</label>
          <span class="weui-form-preview__value">{{attachUnit(baseInfo.totalamount, ' 元')}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">状态</label>
          <span class="weui-form-preview__value">{{baseInfo.statusname}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">备注</label>
          <span class="weui-form-preview__value">{{baseInfo.remark}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">操作人</label>
          <span class="weui-form-preview__value">{{baseInfo.operator}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">创建时间</label>
          <span class="weui-form-preview__value">{{baseInfo.createtime}}</span>
        </div>
        <div class="weui-form-preview__item" v-if="baseInfo.files && baseInfo.files.length > 0">
          <label class="weui-form-preview__label">附件</label>
          <a v-for="(item, index) in baseInfo.files" :href="item.url">
            <span class="weui-form-preview__value">{{item.imagename}}</span>
          </a>
        </div>
      </div>
    </div>
    <!--    明细信息-->
    <div class="weui-panel__hd" style="text-align: left;">物流订单明细</div>
    <div class="weui-panel__bd section" style="background: #fff;padding-top: 3px;">
      <div class="weui-grids">
        <div class="row hd">
          <a href="" style="pointer-events:none;" class="weui-grid js_grid fir">
            <p class="weui-grid__label">
              车牌号
            </p>
          </a>
          <a href="" style="pointer-events:none;" class="weui-grid js_grid sec">
            <p class="weui-grid__label">
              运费金额
            </p>
          </a>
          <a href="" style="pointer-events:none;" class="weui-grid js_grid thr">
            <p class="weui-grid__label">
              其他费用
            </p>
          </a>
          <a href="" style="pointer-events:none;" class="weui-grid js_grid fiv">
            <p class="weui-grid__label">
              订单号
            </p>
          </a>
        </div>
        <template v-for="item in wlOrders">
          <div class="row">
            <a href="" style="pointer-events:none;" class="weui-grid js_grid fir">
              <p class="weui-grid__label">
                {{item.carcode}}
              </p>
            </a>
            <a href="" style="pointer-events:none;" class="weui-grid js_grid sec">
              <p class="weui-grid__label">
                {{item.wlamount}}
              </p>
            </a>
            <a href="" style="pointer-events:none;" class="weui-grid js_grid thr">
              <p class="weui-grid__label">
                {{item.othercost}}
              </p>
            </a>
            <a href="" style="pointer-events:none;" class="weui-grid js_grid fiv">
              <p class="weui-grid__label">
                {{item.linkecodes}}
              </p>
            </a>
          </div>
        </template>
<!--        <p>收起︽</p>-->
      </div>
      <div v-if="baseInfo.items && baseInfo.items.length > 10">
        <p class="morebtn" v-if="!showMore" @click="openItems">展开 ↓</p>
        <p class="morebtn" v-if="showMore" @click="closeItems">收起 ↑</p>
      </div>
    </div>
    <!--    审批记录-->
    <SalesOperationLogs7 :orderid="id" :srguid="baseInfo.srguid" :departid="baseInfo.departid" :flowid="flowid"></SalesOperationLogs7>
    <!--    </div>-->
    <!--  </div>-->
    <CommentBom v-if="isReady" :flowid="flowid" :nodeid="nodeid" :id="id" :srguid="baseInfo.srguid" :departid="baseInfo.departid" :model="baseInfo" navgateUrl="/farepay2/FarepayList" ></CommentBom>
  </div>
</template>

<script>
  import SalesOperationLogs7 from '../common/SalesOperationLogs7'
  import CommentBom from '@/components/common/CommentBom'

  export default {
    name: 'ViewFarepay2',
    data() {
      return {
        flowid: 38,
        userid: localStorage.userId,//'oIuV2v77MaLCAQILhjI6h6oTWpHI',
        id: '',
        baseInfo: {},
        baseItems: [],
        qaform: [],
        qaFormImg: [],
        orderfiles: [],
        isReady: false,
        showMore: false,
        wlOrders: []
      }
    },
    components: {
      SalesOperationLogs7,
      CommentBom
    },
    created() {

    },
    mounted() {
      this.id = this.$route.query.id;
      this.getbaseInfo(this.id);
      //图片浏览器
      $('.weui-panel').on('click', '.uploaderFiles .attachimg', function () {
        var num = $(this).parent().children().not(".exp").length;
        var imgArr = [];
        for (var i = 0; i < num; i++) {
          imgArr.push($(this).parent().find('.attachimg').eq(i).data('img'));
        }
        var pnum = $(this).parent().find('.exp').length;
        var index = pnum > 0 ? $(this).index() - pnum : $(this).index();
        var pb = $.photoBrowser({
          items: imgArr,
          initIndex: index
        });
        pb.open();
      });

    },
    methods: {
      openItems: function() {
        this.wlOrders = this.baseInfo.items;
        this.showMore = true;
      },
      closeItems: function() {
        this.wlOrders = this.baseInfo.items.slice(0, 10);
        this.showMore = false;
      },
      packUnit: function(unit, currency) {
        return unit != undefined && unit != '' ? currency == 2 ? '美元/' + unit : '元/' + unit : '';
      },
      getbaseInfo: function (id) {
        this.axios({
          method: 'get',
          url: `/prod-api/farepay/farepay/${id}`,
        }).then(response => {
          if (response.data.code == 200) {
            let data = response.data;
            this.baseInfo = data.data || {};
            if (this.baseInfo.items && this.baseInfo.items.length > 10) {
              this.wlOrders = this.baseInfo.items.slice(0, 10);
              this.showMore = false;
            } else {
              this.wlOrders = this.baseInfo.items;
            }
            // this.baseItems = response.data.items;
          } else if (response != undefined && response.data != undefined && response.data.msg == 'sessionTimeOut') {
            //不不设置提示
          } else {
            this.toastError('系统错误');
          }
          this.isReady = true;
        });
      },
    }
  }
</script>
